package com.laiketui.app.controller;

import com.laiketui.common.api.ocr.VerifyService;
import com.laiketui.core.domain.Result;
import com.laiketui.core.exception.LaiKeAPIException;
import com.laiketui.root.annotation.HttpApiMethod;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class VerifyController {

    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private VerifyService verifyService;

    @RequestMapping("verifyIdCard")
    @HttpApiMethod(urlMapping = "app.verify.verifyIdCard")
    public Result verifyIdCard(String name, String idNumber) throws Exception {
        try{
            //根据识别类型获取
            return Result.success(verifyService.verifyIdCard(name,idNumber));
        }catch (LaiKeAPIException e){
            return Result.error(e.getCode(), e.getMessage(), e.getMethod());
        }
    }

    @RequestMapping("verifyBusinessLicense")
    @HttpApiMethod(urlMapping = "app.verify.verifyBusinessLicense")
    public Result verifyBusinessLicense(String creditCode, String companyName,String legalPerson) throws Exception {
        try{
            return Result.success(verifyService.verifyBusinessLicense(creditCode,companyName,legalPerson));
        }catch (LaiKeAPIException e){
            return Result.error(e.getCode(), e.getMessage(), e.getMethod());
        }
    }

}
